package cn.org.rapid_framework.generator.ext;

import cn.org.rapid_framework.generator.GeneratorFacade;
import cn.org.rapid_framework.generator.GeneratorProperties;
import cn.org.rapid_framework.generator.provider.db.DataSourceProvider;
import cn.org.rapid_framework.generator.util.SystemHelper;

import java.io.File;

/**
 * Created by vic on 2017/8/7.
 */
public class Line {
    private static String basepackage = "com.audaque.module.oa"; //文件头命名
    private static String namespace = "pages";

    private static String inRoot = "";//模版路径
    private static String outRoot = ".\\generator-output"; //输出路径
    private static String jdbc_username = "dsol";
    private static String jdbc_password = "eHS44s";
    private static String jdbc_url = "jdbc:mysql://192.168.29.28:3306/zhys_yd_new";
    private static String jdbc_driver = "com.mysql.jdbc.Driver";

    public static void main(String[] args) throws Exception {
        String tableName = "log_http";

        DataSourceProvider.setJdbc_driver(jdbc_driver);
        DataSourceProvider.setJdbc_url(jdbc_url);
        DataSourceProvider.setJdbc_username(jdbc_username);
        DataSourceProvider.setJdbc_password(jdbc_password);

        GeneratorFacade facade = new GeneratorFacade(); //这里有设置输出路径
        facade.getGenerator().setIncludes(null);//匹配模版
        facade.getGenerator().addTemplateRootDir(new File("template"));//模版路径

        //配置数据源 等信息
        facade.generateByTable(tableName);
        if (SystemHelper.isWindowsOS) {
            Runtime.getRuntime().exec("cmd.exe /c start " + GeneratorProperties.getRequiredProperty("outRoot").replace('/', '\\'));
        }
    }

}
